package io.github.uicdb.et.recipe;

import io.github.uicdb.et.capability.IElementalHandler;
import lombok.Getter;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.player.StackedContents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeInput;
import org.jetbrains.annotations.NotNull;

public final class ElementRecipeInput implements RecipeInput {
    private final IElementalHandler elementalHandler;
    @Getter
    private final NonNullList<ItemStack> items;
    @Getter
    private final StackedContents stackedContents;
    @Getter
    private final int ingredientCount;
    public ElementRecipeInput(IElementalHandler elementalHandler, NonNullList<ItemStack> items) {
        this.elementalHandler = elementalHandler;
        this.items = items;
        this.stackedContents = new StackedContents();
        int i = 0;

        for (ItemStack itemstack : items) {
            if (!itemstack.isEmpty()) {
                ++i;
                this.stackedContents.accountStack(itemstack, 1);
            }
        }

        this.ingredientCount = i;
    }

    @Override
    public @NotNull ItemStack getItem(int i) {
        return items.get(i);
    }

    @Override
    public int size() {
        return items.size();
    }

    public IElementalHandler elementalHandler() {
        return elementalHandler;
    }

    public NonNullList<ItemStack> stacks() {
        return items;
    }


}
